package com.decade.mapper.impl;

import com.decade.mapper.GoodsMapper;
import com.decade.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.Connection;
import java.util.List;
@Repository
public class GoodsMapperImpl implements GoodsMapper {
    @Autowired
    private SqlSession sqlSession;//SqlSessionTemplate（线程安全）

    @Override
    public List<Goods> findGoods() {//在此方法内部使用sqlSession实现与数据库绘画
        System.out.println("自定义接口实现类");
        List<Goods> list = sqlSession.selectList("com.decade.mapper.GoodsMapper.findGoods");
//        Connection conn =sqlSession.getConnection();

        return list;
    }

    @Override
    public int deleteById(Integer id) {
        return sqlSession.delete("com.decade.mapper.GoodsMapper.deleteById",id);
    }

    @Override
    public int deleteObjects(Integer... ids) {
        return 0;
    }

    @Override
    public int updateById(Goods goods) {
        return sqlSession.update("com.decade.mapper.GoodsMapper.updateById");
    }
}
